home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _1D0EAE932E3E4EC888C4533EC46B750C < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.9 KB  |  70 lines

  1. // ===============================================================
  2. // Fragment Program: Heat Source Pass
  3. // Description: Output heat 
  4. // Last Update: 18/12/2003
  5. // Coder: Tiago Sousa
  6. // ===============================================================
  7.  
  8. #include "../CGVPMacro.csi"
  9.  
  10. MainInput 
  11. {   
  12. #ifdef OPENGL  
  13.   uniform samplerRECT ScreenTexMask : texunit0,
  14.     uniform samplerRECT ScreenTex : texunit1,
  15. #endif
  16. #ifdef D3D  
  17.   uniform sampler2D ScreenTexMask : texunit0,
  18.     uniform sampler2D ScreenTex : texunit1,
  19. #endif    
  20.     uniform sampler2D HeatPaleteTex : texunit2,    
  21.     uniform float4 vHeatConstants
  22. }
  23.  
  24. DeclarationsScript
  25. {
  26.     OUT_T0_T1_T2
  27.     FOUT
  28. }
  29.  
  30. CoreScript
  31. {
  32.     // fetch textures    
  33. #ifdef OPENGL
  34.   float4 vMaskColor = texRECT(ScreenTexMask, IN.Tex0.xy);
  35.     float4 vScreenColor = texRECT(ScreenTex, IN.Tex1.xy);
  36. #endif
  37. #ifdef D3D
  38.   float4 vMaskColor = tex2D(ScreenTexMask, IN.Tex0.xy);
  39.   float4 vScreenColor = tex2D(ScreenTex, IN.Tex1.xy);
  40. #endif
  41.     float4 vHeatColor = tex2D(HeatPaleteTex, vScreenColor.ar); 
  42.         
  43.   // heat decoding
  44.     float4 vConstants=float4(0, 0, 0, 1);                            
  45.                     
  46. #ifdef OPENGL
  47.     // 1st test: strong blue is used for main mask color detection        
  48.     float fColorA=saturate(dot(vMaskColor.xyz, float3(0, 0.25, 0.25)) );
  49.  
  50.     // 2nd test: check alpha mask
  51.     float fColorB=4*( saturate(2*(vMaskColor.w-0.5)) );
  52.  
  53.     float3 fFinalMask=(fColorA<0.5)? vConstants.w: vHeatColor.xyz;
  54.     fFinalMask=(fColorB<0.5)? fFinalMask: vConstants.w;    
  55.     
  56. #endif
  57. #ifdef D3D              
  58.     // 1st test: strong blue is used for main mask color detection        
  59.     float fColorA=saturate(dot(vMaskColor.xyz, float3(0, 0.251, 0.251)) );
  60.  
  61.     // 2nd test: check alpha mask
  62.     float fColorB=4*vMaskColor.w;
  63.  
  64.     float3 fFinalMask=(fColorA<0.49)? vHeatColor.xyz: vConstants.w;
  65.     fFinalMask=(fColorB<0.49)? vConstants.w: fFinalMask;                        
  66. #endif
  67.                                                 
  68.     OUT.Color.xyz = fFinalMask;
  69.     OUT.Color.w = 1;
  70. }